import React,{Component} from "react";
import './GoodList.css'

class GoodList extends Component{

    constructor(props) {
        super(props);
        this.state = {
            books : [
                {id:1,bookName:'Java编程思想',author:'张三'},
                {id:2,bookName:'Java从入门到放弃',author:'李四'},
                {id:3,bookName:'Java从入门到入土',author:'王五'},
                {id:4,bookName:'Java讲义',author:'李刚'}
            ]
        };
    }
    render() {
        return (
            <div>
                商品列表信息
                <br />
                <table border="1" width="600">
                    <thead>
                        <tr>
                            <th>编号</th>
                            <th>书名</th>
                            <th>作者</th>
                        </tr>
                    </thead>
                    <tbody>
                    {
                        this.state.books.map((book,index)=>{
                            return <tr key={book.id} className={index%2==0?'b_r':''}>
                                <td>{book.id}</td>
                                <td>{book.bookName}</td>
                                <td>{book.author}</td>
                            </tr>;
                        })
                    }
                    </tbody>
                </table>

            </div>
        );
    }
}

export default GoodList;